#!/usr/bin/env python2.7
# -*- coding:utf-8 -*- 

# merra.py

import os, sys
from metlib.kits import *
from datakeeper.models import DataSet, DatasetMold

def run():
    try:
        raise DataSet.DoesNotExist
        ds = DataSet.objects.get(name='merra')
        print "Merra exists, not creating."
    except DataSet.DoesNotExist:
        try:
            merra_mold = DatasetMold.objects.get(name='merra')
        except DatasetMold.DoesNotExist:
            print "No such dataset-mold: merra"
            sys.exit(1)
        print "Creating dataset: merra ..."
        ds = DataSet(
                name='merra',
                desc=u'Merra数据集',
                creator='zb',
                version='1.0',
                priority=1000,
                mold=merra,
                protect_data=True,
                public=True,
                free=True
                )
        ds.info = {
            "zh_name": "Merra",
            "desc": "Merra再分析数据",
            "begdt": "19790101",
            "enddt": "20160101",
            "years": ["1979", "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987",
                      "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996",
                      "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005",
                      "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014",
                      "2015"]
        }
        ds.save()

